package org.mathcloud.math.core.generic.variable;

import org.mathcloud.math.core.common.function.FunctionObject;
import org.mathcloud.math.core.common.quantity.QuantityObject;
import org.mathcloud.math.core.common.signature.VariableObjectSignature;
import org.mathcloud.math.core.common.variable.VariableObject;

public class GenericVariable implements VariableObject
{
	public GenericVariable()
	{
		quantity = null;
		function = null;
		refVariable = null;
	}
	
	@Override
	public VariableObjectSignature getSignature()
	{
		return signature;
	}

	@Override
	public void assign(QuantityObject arg0)
	{
		quantity = arg0;
		function = null;
		refVariable = null;
	}

	@Override
	public void assign(VariableObject arg0)
	{
		quantity = null;
		function = null;
		refVariable = arg0;		
	}

	// for future use
	@Override
	public void assign(FunctionObject arg0)
	{
		quantity = null;
		function = arg0;
		refVariable = null;
	}

	@Override
	public QuantityObject getQuantity()
	{
		if (quantity!=null)
			return quantity;
		else if (function!=null)
			return function.getQuantityValue();
		else if (refVariable!=null)
			return refVariable.getQuantity();
		else return null;
	}

	protected VariableObjectSignature signature;
	protected QuantityObject quantity;
	protected FunctionObject function;
	protected VariableObject refVariable;
}
